/****************************************************************************
*					Environment
*
*	Description:
*
*
****************************************************************************/

#ifndef _Environment_H
#define _Environment_H

#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>
#include "boost/filesystem/operations.hpp"
#include "boost/filesystem/path.hpp"


class Environment {

  private:

	 // Parameters from config-file
	std::multimap<std::string, std::string> configFileParams; 

  protected:
    
	// Type defenition (for simplifying the code)
	typedef boost::tokenizer<boost::char_separator<char> >			token_separator;
	typedef std::multimap<std::string,std::string>::const_iterator	mm_c_iter;
  
	// Function to store parameters from a single line in config file represented as a set of tokens
	int processTokens (token_separator tokens);
	// Removes spaces and tabs in the beginning and in the end of the sentance
	int moveSpaces (std::string &str) const;
	// Creats directory with a given name
	int createDir (std::string dir);

  public:
	
	// Standard constructor
	Environment ();

	// Standard constructor
	~Environment ();
	
	// Reads config file
	int readConfigFile (const char* filename);
	
	// Reads config parameters from input data to the process
	int readConfigParams (int argc, char** argv);
	
	// Saves parametes to the specified file
	int saveFile (const std::string fileName);
	
	// Gets parameter with a given name
	int getStringParamValue (std::string& value, const std::string& name) const;
	int getDoubleParamValue (double& value, const std::string& name) const;
	int getIntParamValue (int& value, const std::string& name) const;
	int getBoolParamValue(bool& value, const std::string& name) const;
	int getStringSetParamValue(std::set<std::string>& value, const std::string& name) const;
	int getDoubleSetParamValue(std::set<double>& value, const std::string& name) const;
	int getIntSetParamValue (std::set<int>& value, const std::string& name) const;
  
	// Sets new parameter value
	template<class T> void setParamValue(const T& value, const std::string& name);
	void setParamValues(const std::set<std::string>& value, const std::string& name);
	
	// Removes all elements in the environment
	void clear();

}; // end of class

#endif // _Environment_H 
